package com.yuma.elasticsearch.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)  // 忽略未知字段  index _doc/10 {id,name,password,age,grade,birthday}
@Document(indexName = "user")  // 要生成的索引 ,映射有
public class User {
    @Id   // 主键
    private int id;
    @Field(type = FieldType.Text, index = true,  store = false)
    private String name;
    @Field(type = FieldType.Keyword, index = false,  store = false)
    private String password;
    @Field(type = FieldType.Integer, index = true,  store = false)
    private Integer age;
    @Field(type = FieldType.Keyword, index = true,  store = false)
    private String grade;

    public User(int id, String name, String password, Integer age, String grade) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.age = age;
        this.grade = grade;
    }

    public User() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", age=" + age +
                ", grade='" + grade + '\'' +
                '}';
    }
}